/*
 * @Author: liyin 2179253556@qq.com
 * @Date: 2022-11-16 08:08:03
 * @LastEditors: liyin 2179253556@qq.com
 * @LastEditTime: 2025-09-18 14:21:07
 * @FilePath: \consumption-data-screen\src\main-dev.js
 * @Description: 这是默认设置,请设置`customMade`, 打开koroFileHeader查看配置 进行设置: https://github.com/OBKoro1/koro1FileHeader/wiki/%E9%85%8D%E7%BD%AE
 */
import Vue from 'vue'
import App from './App.vue'
import router from './router'
import store from './store'
import './plugins/index.js'
import './assets/css/global.css'
import './assets/css/bass.less'
import './plugins/element.js'
import Util from './util/util.js'
// 导入封装的websocket组件
// import * as socketApi from './websocket/socket'
import axios from 'axios'
import './assets/fonts/iconfont.css'
// 引入rem.js
import './util/rem.js'
import Footer from './components/Common/Footer.vue'
import Header from './components/Common/Header.vue'
import dataV from '@jiaminghi/data-view'
import * as echarts from 'echarts'
// axios.defaults.baseURL = '/'
if (process.env.NODE_ENV === 'development') {
  // 设置默认本地开发
  axios.defaults.baseURL = '/Consume'
} else if (process.env.NODE_ENV === 'production') {
  let url = ''
  if (window.location.pathname.indexOf('Consume') !== -1) {
    // 存在
    url = '/Consume'
  } else {
    url = '/Consume'
  }
  // 默认正式
  axios.defaults.baseURL = url
}
// 配置拦截器，携带token令牌
// 在request拦截器中，展示进度条Nprogress.start()
axios.interceptors.request.use(config => {
  // console.log(window.sessionStorage.getItem('token'))
  if (window.sessionStorage.getItem('token')) {
    config.headers.Token = window.sessionStorage.getItem('token')
  } else {
    config.headers.Accesstoken = 'eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJpZCI6IjciLCJuaWNrX25hbWUiOiJcdTViOGZcdTgwNTQiLCJsb2dpbl9uYW1lIjoiaG9uZ2xpYW4iLCJyb2xlX2lkIjoiMSIsIm1lbnVzX2lkcyI6IjYsNyw5LDEwLDExLDM1LDE4LDE5LDIwLDIxLDIyLDIzLDI1LDI0LDUxLDI2LDMxLDEyLDEzLDE0LDE1LDE2LDE3LDQ2LDUwLDI3LDI4LDI5LDMwLDMyLDMzLDM0LDM4LDQxLDQ4LDUyLDM2LDM3LDQyLDQzLDQ3LDQ0LDQ1LDIsMyw0LDUiLCJhZ2VuY3lfaWQiOiI5IiwiYWdlbmN5X2lkcyI6WyI5IiwiMTAiLCIxMSIsIjEyIiwiMTMiLCIxNCJdfQ.Vg4uRueXWyUX5p7dg_1hhdrq5wnCSpqRPxPegfawD8g'
  }
  return config
})
// 配置response响应拦截器
// 在response拦截其中，结束进度条Nprogress.done()
axios.interceptors.response.use((config) => {
  // window.sessionStorage.setItem('statusCode', config.status)
  return config
}, (err) => {
  return err.response
})
Vue.prototype.$http = axios
// 全局注册使用util类
Vue.prototype.$util = Util
// 全局注册使用websocket
// Vue.prototype.$socket = socketApi
Vue.config.productionTip = false
Vue.prototype.$echarts = echarts
Vue.component('Footer', Footer)
Vue.component('Header', Header)
Vue.use(dataV)
new Vue({
  router,
  store,
  render: h => h(App)
}).$mount('#app')
